﻿#include "snake.h"

void Snake::updatePos()
{

    for(int i=len-1;i>1;i--){
        points[i]=points[i-1];
    }
    switch (dir) {
    case UP:
        points[0].setY(points[0].y()-16);
        break;
    case DOWN:
        points[0].setY(points[0].y()+16);
        break;
    case LEFT:
         points[0].setX(points[0].x()-16);
        break;
    case RIGHT:
        points[0].setX(points[0].x()+16);
        break;
    default:
        break;
    }

}

Snake::Snake(QObject *parent)
    : QObject(parent),
    len(3),dir(UP)

{

}
